package com.ruoyi.web.controller.server;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.system.domain.vo.EApiLogVo;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.EApiLog;
import com.ruoyi.system.service.IEApiLogService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 接口使用日志Controller
 *
 * @author ruoyi
 * @date 2022-03-23
 */
@RestController
@RequestMapping("/server/apiLog")
public class EApiLogController extends BaseController
{
    @Autowired
    private IEApiLogService eApiLogService;

    /**
     * 查询接口使用日志列表
     */
    @PreAuthorize("@ss.hasPermi('server:apiLog:list')")
    @GetMapping("/list")
    public TableDataInfo list(EApiLog eApiLog)
    {
        startPage();
        List<EApiLog> list = eApiLogService.selectEApiLogList(eApiLog);
        return getDataTable(list);
    }

    /**
     * 导出接口使用日志列表
     */
    @PreAuthorize("@ss.hasPermi('server:apiLog:export')")
    @Log(title = "接口使用日志", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EApiLog eApiLog)
    {
        List<EApiLogVo> list = eApiLogService.selectEApiLogVoList(eApiLog);
        ExcelUtil<EApiLogVo> util = new ExcelUtil<EApiLogVo>(EApiLogVo.class);
        util.exportExcel(response, list, "接口使用统计");
    }
}
